# Maintainer: Balló György <ballogyor+arch at gmail dot com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - disable distcc, breaks meson finding miniupnpc

pkgname=fragments
pkgver=3.0.1
pkgrel=2
pkgdesc='BitTorrent client for GNOME'
arch=(x86_64)
url='https://apps.gnome.org/Fragments/'
license=(GPL-3.0-or-later)
options=(!distcc)
depends=(
  dconf
  gcc-libs
  glib2
  glibc
  gtk4
  hicolor-icon-theme
  libadwaita
  openssl
  transmission-cli
  zlib
)
makedepends=(
  git
  meson
  rust
)
options=(!lto)
source=(
  "git+https://gitlab.gnome.org/World/Fragments.git#tag=$pkgver"
  fragments-window-icon.patch
)
b2sums=(
  13afaddc26eab6e68199d0d1d8889c96bba394c5be63d641741d9994ae243e79e31ac243afc624b835cc575028723ecea556bfb419e0e01577429f6035f80c77
  968c7610283893aa327a76e68af3ed24dcbd0c61d24c09d524d5bb2791904b37b1da106e2118725eb188bec5e03b66bd04f93b7c0f6f835a573447224f7564b5
)

prepare() {
  cd Fragments

  # https://gitlab.gnome.org/World/Fragments/-/merge_requests/183
  patch -Np1 -i ../fragments-window-icon.patch
}

build() {
  # Use LTO
  #export CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

  # Use debug
  #export CARGO_PROFILE_RELEASE_DEBUG=2

  arch-meson Fragments build
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
}
